<template>
	<div>
		<el-row :gutter="20">
			<el-col :md="24">
				<el-card class="box-card" style="height:346px">
					<div slot="header" class="clearfix">
						<span>CPU详情</span>
					</div>
					<div >
						<v-Cpuinfo ref="CPUINFO"></v-Cpuinfo>
					</div>
				</el-card>
			</el-col>
			<el-col :md="24" style="margin-top: 30px;">
				<el-card class="box-card" style="height:346px">
					<div slot="header" class="clearfix" >
						<span>内存详情</span>
					</div>
					<div >
						<v-MemoryInfo ref="MEMORYINFO"></v-MemoryInfo>
					</div>
				</el-card>
			</el-col>
		</el-row>
		<!-- <el-row :gutter="20" style="margin-top: 10px;">
			
		</el-row> -->
	</div>
</template>>

<script>
	import {
		fetchData
	} from '@/api/index.js';
	import bus from "common/bus.js";
	import vCpuinfo from './Cpuinfo.vue'
	import vMemoryInfo from './MemoryInfo.vue';
	import {
		GetItem
	} from "@/utils/dataStore";
	export default {
		data() {
			return {
				postData: {
					opera: 'hostconnect',
					curPage: 1,
					pageSize: 2000,
					sort: {
						sortColumn: 'monid',
						sortOrders: 'asc'
					},
					filtersType: 'fuzzyquery',
					filters: {

					},
				},
				initData: '',
				selectedMonID: ''

			}
		},
		components: {
			vCpuinfo,
			vMemoryInfo,

		},
		created() {
			GetItem(sessionStorage.getItem('PushId')).then(_ => {
				this.selectedMonID = _[0].articleAddress;
				this.initGetData();
			})
			bus.$emit("timerNewTodo", {
				name: this.timerName,
				eventName: this.timerEventName,
				interval: this.timerInterval,
				intervalNow: 0,
			});
		},
		mounted() {
			bus.$on("ItemMonitorALL", (msg) => {
				this.selectedMonID = msg;
				this.initGetData();
			});
		},
		computed: {

		},
		methods: {
			initGetData() {
				fetchData({
					postData: JSON.stringify(this.postData)
				}).then((res) => {
					if (res) {
						this.initData = res;
						bus.$emit('ItemMonitorInitChart', [res, this.selectedMonID])
					}
				});
			},

		},
		beforeDestroy() {
			bus.$off("ItemMonitorALL")


		},

	}
</script>

<style scoped lang="scss">


</style>
